package chapter21.section3;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by lzy
 * Date: 2018/6/4
 * @author liuziyang
 */
public abstract class PairManager {
    Pair p = new Pair();
    AtomicInteger checkCounter = new AtomicInteger(0);
    private final List<Pair> storage = Collections.synchronizedList(new ArrayList<>());
    synchronized Pair getPair(){
        return new Pair(p.getX(), p.getY());
    }

    void store(Pair p) {
        storage.add(p);
        try {
            TimeUnit.MILLISECONDS.sleep(50);
        } catch (InterruptedException ignore) {

        }
    }

    public abstract void increment();
}
